#include "libmri.h"

int wavelet_sizes (int *& S, int m, int n, int L, int lf)
{
	if (not S) S = new int[2*(L+2)];

	S[0 + 2*(L+1)] = m;
	S[1 + 2*(L+1)] = n;

	int nc = 0;

	for (int l = L; l >= 1; --l){
		S[0 + 2*l] = (S[0 + 2*(l+1)] + lf-1) / 2;
		S[1 + 2*l] = (S[1 + 2*(l+1)] + lf-1) / 2;

		nc += 3*(S[0 + 2*l] * S[1 + 2*l]);
	}

	nc += (S[0] = S[0 + 2*1]) * (S[1] = S[1 + 2*1]);

	return nc;
}


int get_wavelet_filters (filt_t *& filters)
{
	static const int lf = 4;

	// Daubechies-2 Wavelet
	static float filt_data[4 * lf] = {
		-0.129410,  0.224144,  0.836516,  0.482963, 
		-0.482963,  0.836516, -0.224144, -0.129410, 
		 0.482963,  0.836516,  0.224144, -0.129410, 
		-0.129410, -0.224144,  0.836516, -0.482963
	};

	filters = new filt_t [4 * lf];

	for (int i = 0; i < 4*lf; ++i) filters[i] = filt_data[i];

	return lf;
}
